package link.ten_fei.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import link.ten_fei.Bean.Pl_Num;
import link.ten_fei.service.ShowService;
import link.ten_fei.service.ShowServiceImpl;
import net.sf.json.JSONArray;

/**
 * Servlet implementation class ShowServlet
 */
@WebServlet("/show.action")
public class ShowServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#HttpServlet()
	 */
	public ShowServlet() {
		super();
		// TODO Auto-generated constructor stub
	}

	/**
	 * @see HttpServlet#service(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		//将分组查询的数据进行转换成json数组
		response.setCharacterEncoding("utf-8");
		request.setCharacterEncoding("utf-8");
		PrintWriter pWriter = response.getWriter();
		ShowService mainservice = new ShowServiceImpl();
		List<Pl_Num> doc = mainservice.show();
		JSONArray json = JSONArray.fromObject(doc);
		pWriter.print(json);
	}

}
